<?php

	class ViewstackWidget extends EbWidget
	{
		public function render()
		{
			$target = $this->target;
			
			echo '<ul id="'.$target.'-menu"></ul>';
			?>
			<script type="text/javascript">
			$(function()
			{
			var buffer = '';
			var target = "#<?php echo $target;?>";
			
			$($(target).children()).each(function(i) {buffer += '<li><a href="#">' + $(this).attr("name") + '</a></li>';});
		
			$(target + "-menu").html(buffer);
			$(target + "-menu LI").click(function() {$(target + "-menu LI").removeClass("active");$(this).addClass("active");$($(target).children()).hide();$(target + " DIV[name='" + $(this).text() + "']").fadeIn(200);});
			$($(target + "-menu LI").get(0)).addClass("active");$($(target).children()).hide();$($(target + " DIV").get(0)).show();
			
			});
			</script>
			<?php
		}	
	}

?>